package com.kfm.hotel.controller;

import com.kfm.hotel.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.TimeUnit;

@RestController
@RequestMapping("/redis")
public class RedisController {

    @Autowired
    private RedisTemplate redisTemplate;

    @GetMapping("/string")
    public R string(){

        // setex: set with expire
        redisTemplate.opsForValue().set("name", "kaifamiao", 10, TimeUnit.SECONDS);
        return R.ok("success");
    }
}
